local M = {}

function M.createLogic(name, game_func)
  return function()
    local logic = GameLogic:subclass(name)

    function logic:chooseGenerals()
      local room = self.room
      for _, p in ipairs(room.players) do
        local avatar = p._splayer:getAvatar()
        if avatar == "anjiang" then
          avatar = table.random { "blank_shibing", "blank_nvshibing" }
        end
        local avatar_general = Fk.generals[avatar] or Fk.generals["sunce"] or Fk.generals["diaochan"]
        room:setPlayerProperty(p, "general", avatar_general.name)
        room:setPlayerProperty(p, "kingdom", avatar_general.kingdom)
        room:setPlayerProperty(p, "role_shown", true)
      end
    end
    function logic:broadcastGeneral() end
    function logic:attachSkillToPlayers() end
    function logic:prepareForStart() end
    function logic:action()
      game_func(self.room)
    end

    return logic
  end
end

return M
